package com.xhs.controller;

import com.xhs.dto.request.AddCompanyParams;
import com.xhs.dto.request.PageCompanyParams;
import com.xhs.message.ReturnResult;
import com.xhs.service.CapCompanyInfoService;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @desc:
 * @projectName: spring-boot-demo
 * @author: xhs
 * @date: 2023-8-14 014 21:54
 * @version: JDK 1.8
 */
@RestController
public class CompanyController {

    @Resource
    private CapCompanyInfoService companyInfoService;

    /**
     * 获取用户信息
     *
     * @return ReturnResult<Object>
     */
    @GetMapping("/getList")
    public ReturnResult<Object> getList() {
        return companyInfoService.getCompanyInfo();
    }

    /**
     * 新增企业
     *
     * @param addCompanyParams 入参
     * @return ReturnResult<Object>
     */
    @PostMapping("/addCompanyInfo")
    public ReturnResult<Object> addCompanyInfo(@Validated @RequestBody AddCompanyParams addCompanyParams) {
        return companyInfoService.addCompanyInfo(addCompanyParams);
    }

    /**
     * 分页查询企业
     *
     * @param pageCompanyParams 查询条件
     * @return ReturnResult<Object>
     */
    @PostMapping("/pageList")
    public ReturnResult<Object> pageList(@Validated @RequestBody PageCompanyParams pageCompanyParams) {
        return companyInfoService.pageList(pageCompanyParams);
    }
}
